package com.nothingboard.module.code.dao.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.nothingboard.module.code.dao.CodeDao;
import com.nothingboard.module.code.model.CodeDto;
import com.nothingboard.module.code.model.CodeLocalVo;
import com.nothingboard.module.code.model.CodeSearchDto;
import com.nothingboard.module.code.model.CodeVo;

@Repository("codeDao")
public class CodeDaoImpl extends SqlMapClientDaoSupport implements CodeDao {
	
	@Resource(name="sqlMapClient")
	public void setSuperSqlMapClient(SqlMapClient sqlMapClient){
		super.setSqlMapClient(sqlMapClient);
	}

	@SuppressWarnings("unchecked")
	public List<Object> getCodeChildList(CodeSearchDto dto) throws DataAccessException {
		return getSqlMapClientTemplate().queryForList("code.getCodeChildList", dto);
	}

	@Override
	public Object insertCode(CodeVo vo) throws DataAccessException {
		return getSqlMapClientTemplate().insert("code.insertCode", vo);
	}
	
	@Override
	public void insertCodeLocal(CodeLocalVo vo) throws DataAccessException {
		getSqlMapClientTemplate().insert("code.insertCodeLocal", vo);
	}

}
